﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="B2B.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<h2>AdminUpdatePostBuyRequest</h2>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HEAD" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="main_content" runat="server">
    <script type="text/javascript">

        function Update() {
            var tinhtrang = document.getElementById("TinhTrang");
            var ma = document.getElementById("hidMaSPMua");
            var json = {
                id: ma.value,
                TinhTrang: tinhtrang.value
            };
            $.ajax({
                url: '/Admin/AdminUpdatePostBuyRequest',
                type: 'POST',
                contentType: 'application/json',
                dataType: 'json',
                data: JSON.stringify(json),
                success: function (response) {
                    alert(response);
                }
            });
            alert("Update success");
        }
    </script>
    <form name="form1" id="form1" runat="server">
        
    <!--Bắt đầu post a buying request-->
    <div align="left">
        <div><h3>Post a Buying Request</h3></div>
        <div>Tell The Supplier What You Want</div>
        <div>
            <!--Bắt đầu bảng post a buying Request-->
            <% var sp = ((PostBuyRequest)((ArrayList)ViewData["SPMua"])[0]); %>
            <table>
                <tr>
                    <th style="width: 280px">Product Name:</th>
                    <td style="width: 228px"><%=sp.TenSanPham %></td>
                </tr>

                <tr>
                    <th style="width: 280px; height: 62px;">Product Category: </th>
                    <td style="width: 228px; height: 62px;"> <%= sp.TenDanhMuc %></td>
                </tr>

                 <tr>
                    <th style="width: 280px;">Product Detailed Specification: </th>
                    <td style="width: 228px;"><%=sp.ChiTiet %></td>
                </tr>

                <tr>
                    <th style="width: 280px;">Relevant Files to the Request: </th>
                    <td style="width: 228px;"><img src="../../Images/Product/<%=sp.HinhAnh %>"/></td>
                </tr>

                <tr>
                    <th style="width: 280px">Estimated Order Quantity: </th>
                    <td style="height: 42px"><%=sp.SoLuongCanMua %></td>
                </tr>
                  
                <tr>
                    <th style="width: 280px">Status: </th>
                    <td style="height: 42px" id="rowTinhTrang">
                        <select id="TinhTrang">
                            <% switch (sp.TinhTrang) 
                               {
                                   case 0: %>
                                        <option value="0" selected>Waiting accept</option>
                                        <option value="1">Accept</option>
                                        <option value="2">Refuse</option>
                                        <%break;%>
                                <% case 1: %>
                                        <option value="0">Waiting accept</option>
                                        <option value="1" selected>Accepted</option>
                                        <option value="2">Refuse</option>
                                        <%break;%>
                                <% case 2: %>
                                        <option value="0">Waiting accept</option>
                                        <option value="1">Accepted</option>
                                        <option value="2" selected>Refuse</option>
                                        <%break;%>
                                <% default: %>
                                        <option value="0">Waiting accept</option>
                                        <option value="1">Accepted</option>
                                        <option value="2">Refuse</option>
                                        <%break;%>
                            <% } %>                            
                        </select>
                    </td>
                </tr>

               <tr>
                  <td style="width: 280px"></td>
                   <td style="width: 228px">
                       <input type="button" value="Update" onclick="Update()"/>
                       <input type="hidden" value="<%=sp.MaSanPhamMua.ToString() %>" id="hidMaSPMua"/>
                   </td>
               </tr>

            </table>
            <!--Kết thúc bảng post a buying Request-->
        </div>
    </div>
    <!--Kết thúc post a buying request-->
    </form>
</asp:Content>
